var Alert={
	hint:function(message){
		var alert=document.getElementById("alerts");
		//防止重复
		if(null==alert){
			var tagDiv=document.createElement("div");
			tagDiv.id="alerts";
			var offsetWidth=document.body.offsetWidth;
			tagDiv.style="z-index:9999;position: fixed;display:flex;align-items:center;justify-content:center;height:100%;width:100%;";
			tagDiv.innerHTML="<p style='color:#000;background:#fff;font-size:14px;padding-left:20px;padding-right:20px;padding-top:10px;padding-bottom:10px;border:1px solid #666;box-shadow:1px 1px 1px #999999;'>" +message+ "</p>";
			document.body.insertBefore(tagDiv,document.body.children[0]);
			setTimeout(function(){
				document.getElementById("alerts").parentNode.removeChild(document.getElementById("alerts"));
			},2000)
		}
	},
	code:function(title,htmlmessage){
		var alert=document.getElementById("alert");
		//防止重复
		if(null==alert){
			var bgkDiv=document.createElement("div");
			var allDiv=document.createElement("div");
			bgkDiv.id="bgk";
			allDiv.id="alert";
			allDiv.style="background:#fff;z-index:9999;background:#fff; position: fixed;display:flex;align-items: center;height:100%;justify-content:center;left: 50%;right: 50%;";
			var tagDiv="<div style='z-index:9998;position:fixed;background:#fff;border:1px solid #666;overflow:hidden;box-shadow:1px 1px 1px #999999;top:25%;'><p>"+title+"</p><p style='font-size:14px;padding-left:50px;padding-right:50px;'>"+htmlmessage+"</p><p><button id='close' style='width: 70px;height:30px;'>关闭</button></p></div>";
			allDiv.innerHTML=tagDiv;
			document.body.insertBefore(allDiv,document.body.children[0]);
			document.getElementById("close").onclick=function(){
				document.getElementById("alert").parentNode.removeChild(document.getElementById("alert"));
			}
		}
	},
	loading:function(close){
		var loading=document.getElementById("loading");
		if(close&&null!=loading){
			document.getElementById("loading").parentNode.removeChild(document.getElementById("loading"));
			document.getElementById("bgk").parentNode.removeChild(document.getElementById("bgk"));
			return;
		}
		if(null==loading){
			var bgkDiv=document.createElement("div");
			var allDiv=document.createElement("div");
			bgkDiv.id="bgk";
			allDiv.id="loading";
			bgkDiv.style="background:#e1e1e1;opacity:0.5;z-index:9997; position: fixed;height:100%;width:100%;";
			allDiv.style="z-index:9999;position:fixed;display:flex;align-items:center;height:100%;width:100%;justify-content:center;";

			var loadHtml="<div style='z-index:9998;opacity:1;position:fixed;overflow:hidden;top:25%;'><div class='blinking'><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></div></div>";
			allDiv.innerHTML=loadHtml;
			document.body.insertBefore(bgkDiv,document.body.children[0]);
			document.body.insertBefore(allDiv,document.body.children[0]);
		}
	},
	windows:function(id,name,url){
		var boxs=document.getElementsByClassName("box");
		if(boxs.length==0){
			var box=document.createElement("div");
			box.className="box";
			box.style="position:fixed;left:0;right:0;width:100%;height:100%;"
			document.body.insertBefore(box,document.body.children[0]);
		}
		
		var windows=document.createElement("div");
		windows.id="windows"+id;
		windows.className="menuWindows";
		windows.style="display:block;width:70%;height:60%;position:fixed;background:#fff;left:10%;top:10%;border:1px solid #666;";
		//窗口操作
		var handleNav='<div class="windowstitle left" style="width:100%;height:8%;user-select:none;border-bottom:1px solid #e1e1e1;">'+
						'<h4 class="left" style="text-indent:1em;"><b>'+name+'</b></h4>'+
						'<a class="right glyphicon glyphicon-remove" onclick="closeWindows('+id+')"></a>'+
						'<a class="glyphicon glyphicon-stop right" onclick="fullScreen(this)"></a>'+
						'<a class="right glyphicon glyphicon-minus" onclick="shrink(this)"></a>'+
					'</div>';
		var frames='<div style="width:100%;height:92%;"><object type="text/html" data="'+url+'" id="object'+id+'" width="100%" height="100%"></object></div>';
		windows.innerHTML=handleNav+frames;
		document.getElementsByClassName("box")[0].appendChild(windows);
		windowsMove();
	}
}


//窗口关闭
function closeWindows(id){
	$("#windows"+id).remove();
}
//窗口拖动
var leftValue=0;
var topValue=0;
function windowsMove(){
$(".windowstitle").mousedown(function(ev){
	var parent=$(this).parent();
	var disX = ev.pageX - $(this).offset().left;//求出鼠标距离拖拽的div左边框的距离；
    var disY = ev.pageY - $(this).offset().top;
	$(".box").mousemove(function(e){
		var right=$(this).width()-parent.width();//窗口可离左边的距离
		var bottom=$(this).height()-parent.height();//窗口可离顶部的距离
		var footerHeight=$("#footericon").height();
		if(parseInt(parent.offset().left)>0){
			if((e.pageX-disX)>0&&(e.pageX-disX)<right){
					parent.css("left",e.pageX-disX);
			}
			
		}
		if(parseInt(parent.offset().top)>0){
			if((e.pageY-disY)>0&&(e.pageY-disY)<bottom){
				parent.css("top",e.pageY-disY);
			}
			
		}
		//全屏开始
		var classNames=parent.prop("class");
		if(classNames.indexOf("fullScreen")==-1&&parseInt(parent.offset().top)==0&&e.pageY>topValue){
			if((e.pageY-disY)>0){
				parent.css("top",e.pageY-disY);
			}
			
		}
		if(classNames.indexOf("fullScreen")==-1&&parseInt(parent.offset().left)==0&&e.pageX>leftValue){
			if((e.pageX-disX)>0){
				parent.css("left",e.pageX-disX);
			}
		}
		//全屏结束
		topValue=e.pageY;
		leftValue=e.pageX;
	})
	$(".box").mouseup(function(e){
		 $(".box").off();
	})
	 return false;
	})
}